'''
Created on Dec 5, 2009

@author: Roni
'''
import orchid
import graph
import logging
import cliques.utils
import urllib
import cliques.cliqueFinder
from xml.sax import saxutils
import re
import webgraphs.intraSiteAnalyzer

class citeseerAnalyzer(webgraphs.intraSiteAnalyzer.intraSiteAnalyzer):
    '''
    classdocs
    '''


    def __init__(self, linksToFetchAndCond, siteQueueAndCond, db,out_file_name , file_format):
        '''
        Constructor
        '''
        webgraphs.intraSiteAnalyzer.intraSiteAnalyzer.__init__(self,linksToFetchAndCond,\
                                                               siteQueueAndCond, db,\
                                                               out_file_name , file_format)

        self.extract_pattern =  re.compile("^http://(citeseer|citeseerx).ist.psu.edu/(?P<itemname>.*)$" )           
        self.filter_pattern = re.compile("^http://(citeseer|citeseerx).ist.psu.edu/.*$")
        self.ignore_list = ['http://citeseer.ist.psu.edu/allcited.html',\
                            'http://citeseer.ist.psu.edu/mostcited.html',\
                            'http://citeseer.ist.psu.edu/cs',\
                            
                            
                            ]
                
    def filter_site(self,str):        
        result = self.filter_pattern.match(str)
        if result is not None:
            return result.group()
        else:
            return None

    def extract_page_name(self,str): 
        ''' Extract the item name from the hostname of a wikipedia page '''
        match_result = self.extract_pattern.match(str)
        return match_result.group("itemname")
     